<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>区域限制</title>

  <link rel="stylesheet" href="/fission/css/iconfont.css">
  <link rel="stylesheet" href="/fission/css/layui.css">
  <link rel="stylesheet" href="/fission/css/common.css">
  <link rel="stylesheet" href="/fission/css/index.css">
  <style>
	/*------------分页部分--------------*/
		.main-container-h{
			padding: 0 40px 20px 40px;
		}
		.pageing-container-h{
			display: flex;
			justify-content: space-between;
		}
		.pageing-content-h{
			line-height: 28px;
		}
		.pageing-content-h a{
			border: 1px solid #e2e2e2;
			padding: 4px 15px;
			color: #333;
			line-height: 28px;
			border-radius: 2px;
		}
		.current{
			background: #1E9FFF !important;
			color: #fff !important;
		}
    /*dao hang*/
     .public-header-nav{
      background: #fff;
      border-bottom: 1px solid #e6e6e6;
      display: flex;
      align-items: center;
      margin: 16px 16px 0 16px;
      border-radius: 4px 4px 0px 0px;
    }
    .public-header-nav li{
      
    }
    .public-header-nav li a{
      color: #333;
      font-size: 14px;
      line-height: 47px;
      padding: 0 20px;
      display: block;
    }
    .public-header-nav-active{
      color: #1E9FFF !important;
      border-bottom: 2px solid #1E9FFF !important;
    }
  </style>
</head>
<body>
  <div style="margin-top: 0;" class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">

    <ul class="public-header-nav">
      <li><a href="mission_list.html">任务列表</a></li>      
      <li><a href="mission_statistics.html">数据分析</a></li>
      <li><a class="public-header-nav-active" href="mission_xianzhi.html">区域限制配置</a></li>
      <li><a href="stage_prize.html">裂变兑换码</a></li>
      <li><a href="short_url.html">短链接配置</a></li>
    </ul>
    <div class="" style="padding: 20px 20px 20px 20px;background: #fff;margin: 16px;">
      
          <div class="layui-form-item">
              <label class="layui-form-label" >高德Key<span style="color:red;">*</span></label>
              <div class="layui-input-inline">
                  <input type="text" id="ak"  style="width: 96%;"required lay-verify="required" placeholder="请填写正确的key" autocomplete="off" class="layui-input" value="{$config->ak}">
              </div>
              <div class="layui-form-mid layui-word-aux">(获取地址：<a target="_blank" href="https://lbs.amap.com/">https://lbs.amap.com/</a>)</div>
          </div>
          
          <div class="layui-form-item" style="margin-bottom: 0;">
            <label class="layui-form-label" ></label>
              <div class="layui-input-inline">
                  <button class="layui-btn layui-btn-normal" id="update_confing">修改配置</button>
              </div>
          </div>
   
  </div>

    </div>
      <!-- 任务列表 Tab -->
      

  <script src="/fission/js/jquery.min.js"></script>
  <script src="/fission/js/layui.all.js"></script>
  <script src="/fission/js/clipboard.min.js"></script>
  <script src="/fission/js/common.js"></script>
  <script src="/js/ajax.js"></script>
  <script>
    $("#update_confing ").click(function () {
        var mchid = $("#ak").val();
        
        if(mchid=="" ){
            tusi("必填项不能为空");
            return false;
        }
        // alert(mchid)
        myAjaxPost(false, true, 'mission_xianzhi.html', { ak:mchid}, function (resp) {
            tusi(resp.msg);
        })
    })
	
  </script>
  
  <script>
    layui.use('laydate', function(){
      var laydate = layui.laydate;

      // 邀请日期范围
      laydate.render({
        elem: '#addTime'
        ,range: true
      });
    })

    layui.use('table', function(){
      var table = layui.table;
      
      table.render({
        elem: '#analysisTable'
        ,url: '/demo/table/user/'
        ,cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
        ,cols: [[
          { field:'id', title: '客户', templet: '#analysisTableClient'}
          ,{ field:'username', title: '所属成员', templet: '#analysisTableService'}
          ,{ field:'sex', title: '添加时间'}
          ,{ field:'city', width:120, title: '流失状态'}
          ,{ field:'sign', title: '完成情况', width: 120, minWidth: 100} //minWidth：局部定义当前单元格的最小宽度，layui 2.2.1 新增
          ,{ field:'experience', width: 120, title: '邀请好友数'}
          ,{ field:'score', width: 170, title: '操作', toolbar: '#analysisTableOperation'}
        ]]
        ,page: true
      });
    });

    // 任务详情
    layui.$('.missions-container').on('click', '.table-btn-details', function() {
      var id = layui.$(this).data('id');
      //console.log(id);
      //console.log(layui.$(this).data('others'));
	  myAjaxPost(false, true, 'get_mission_detail.html', { id:id}, function (resp) {
			if (resp.status == 'success') {
				var data = resp.data;
				$('#qr_code').attr('src',data.qr_code);
				$('#name').html(data.name);
				$('#download_qrcode').attr('href','download_qrcode-'+data.id+'.html');
				$('#yq_link_show').html(data.activityurl);
				$('#yq_link').attr("data-clipboard-text",data.activityurl);
				$('#dateshow').html(data.ctime+' - '+data.end_time);
				$('#usershow').empty();
				var userhtml = '';
				for (var i = 0; i < data.users.length; i++) {
					userhtml += '<li class="owner">';
					userhtml += '<section class="avatar">';
					userhtml += '<img src="'+data.users[i].avatar+'" class="avatar-img">';
					userhtml += '</section>'+data.users[i].name;
					userhtml += '</li>';
				}
				$('#usershow').append(userhtml);
				var tagshow = '';
				for(var i = 0; i < data.select_label.length; i++){
					tagshow += '<span class="layui-badge layui-bg-blue">'+data.select_label[i].split('_')[1]+'</span>';
				}
				$('#tagshow').append(tagshow);
				$('#hy_text').html(data.hy_text_content);
				$('#hy_link_title').html(data.hy_link_title);
				$('#hy_link_desc').html(data.hy_link_desc);
				$('#hy_link_picurl').attr('src',data.hy_link_picurl);
				lookDetails(id);
			}else{
				alert(resp.msg);
			}
	  });
    });
    function lookDetails(id) {
      layer.open({
        type: 1
        ,title: '活动详情'
        ,closeBtn: true
        ,area: '688px'
        ,id: 'missionDetails' //设定一个id，防止重复弹出
        ,content: layui.$('#missionDetailsModel')
        ,success: function(layero){
          var btn = layero.find('.layui-layer-btn');
          btn.find('.layui-layer-btn0').attr({
            href: 'http://www.layui.com/'
            ,target: '_blank'
          });
        }
      })
    }

    // 任务-删除
    layui.$('.missions-container').on('click', '.table-btn-delete', function() {
      var id = layui.$(this).data('id');
      console.log(id);
      deleteMission(id)
    });
    function deleteMission(id) {
      layer.confirm('确定要删除该任务吗？', { icon: 7, title:'提示'}, function(index) {
        // confirm do something
        layer.close(index);
      });
    }

    // 初始化复制功能
    var detailsLinkClip = new ClipboardJS('.detailsCopy');
    detailsLinkClip.on('success', function() {
      layer.msg('复制成功', { icon: 1});
    })
    detailsLinkClip.on('error', function() {
      // layer.msg('复制失败', { icon: 2});
    })
    
  </script>
</body>
</html>